#include<iostream>
#include<stack>

using namespace std;

string s;
stack<char>aa;

int main()
{
	cin >> s;
	for (auto ch : s)
	{
		if (ch == '(' || ch == '[' || ch == '{')
		{
			aa.push(ch);
		}
		else
		{
			if (ch == ')' && aa.top() == '(')
			{
				aa.pop();
			}
			else if (ch == ']' && aa.top() == '[')
			{
				aa.pop();
			}
			else if (ch == '}' && aa.top() == '{')
			{
				aa.pop();
			}
			else
			{
				cout << "false";
				return 0;
			}
		}

	}
	if (aa.size() == 0)
	{
		cout << "true";
	}
	else
		cout << "false";

	return 0;
}
